/*/////////////////////////////////////////////////////////////////////////////////
/// An
///    ___   ____ ___ _____ ___  ____
///   / _ \ / ___|_ _|_   _/ _ \|  _ \
///  | | | | |  _ | |  | || | | | |_) |
///  | |_| | |_| || |  | || |_| |  _ <
///   \___/ \____|___| |_| \___/|_| \_\
///                              File
///
/// Copyright (c) 2008-2009 Ismail TARIM <ismail@royalspor.com> and the Ogitor Team
//
//This program is free software; you can redistribute it and/or modify it under
//the terms of the GNU Lesser General Public License as published by the Free Software
//Foundation; either version 2 of the License, or (at your option) any later
//version.
//
//This program is distributed in the hope that it will be useful, but WITHOUT
//ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
//FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
//You should have received a copy of the GNU Lesser General Public License along with
//this program; if not, write to the Free Software Foundation, Inc., 59 Temple
//Place - Suite 330, Boston, MA 02111-1307, USA, or go to
//http://www.gnu.org/copyleft/lesser.txt.
////////////////////////////////////////////////////////////////////////////////*/

#pragma once

namespace Ogitors
{
    //! Camera visual helper class
    /* 
        This class encapsulates the visual appearance of camera(s) in Ogitor.
    */
    class OgitorExport CCameraVisualHelper : public CEntityVisualHelper
    {
    public:

        /**
        * Constructor
        */
        CCameraVisualHelper(CBaseEditor *parent);
        /**
        * Destructor
        */
        virtual ~CCameraVisualHelper();
        /**
        * Displays or hides camera helper depending on the flag value
        * @param bShow flag to show/hide camera helper
        */
        virtual void Show(bool bShow);

    private:

        /**
        * Creates camera for the helper
        */
        void _createCamera();

        Ogre::ColourValue       mColour;                /** Camera helper colour */

        // frustum properties
        Ogre::Real              mFrustumLeft;           /** Camera' frustum left boundary */
        Ogre::Real              mFrustumRight;          /** Camera' frustum right boundary */
        Ogre::Real              mFrustumTop;            /** Camera' frustum top boundary */
        Ogre::Real              mFrustumBottom;         /** Camera' frustum bottom boundary */
        Ogre::Real              mNearClipDistance;      /** Camera' frustum clipping distance (near)*/
        Ogre::Real              mFarClipDistance;       /** Camera' frustum clipping distance (far)*/

        Ogre::Real              mQuadNearOffset;        /** @todo Figure this one out */
        Ogre::Real              mQuadFarOffset;         /** @todo Figure this one out */
    
        Ogre::ManualObject*     mVisualHelperObject;    /** Handle to OGRE based manual object that represents camera */

        // scenemanager where our visual object belongs to
        Ogre::SceneManager*     mSceneManager;          /** Handle of scene manager */

        // visual helper materials
        Ogre::MaterialPtr       mMaterial;              /** Helper' material handle */

        // resource group of the internal material
        Ogre::String            mResourceGroup;         /** Resource group for the camera helper */

        OgitorsScopedConnection m_PropConnections[3];   /** Properties for camera helper */

        /**
        * Delegate function that is called when Field of View (FOV) is changed (i.e. when camera is displaced)
        * @param value new FOV value 
        */
        void OnFOVChange(Ogre::Any value);
        /**
        * Delegate function that is called when clipping distance (near or far) is changed
        * @param value new near/far clipping value(s)
        */
        void OnClipDistanceChange(Ogre::Any value);
        /**
        * Delegate function that is called when visual helper is selected/deselected
        * @param value selection/deselection flag
        */
        void OnSelectionChange(Ogre::Any value);
    };
}